<template>
	<view class="myActivity">
		<!-- 活动列表 -->
		<u-sticky>
			<u-tabs :list="listed" active-color="#FA9700" :is-scroll="false" :current="current" @change="change"></u-tabs>
		</u-sticky>
		<view-NoData v-if="hongList.length==0">
			
		</view-NoData>
		 <nearlist :list="hongList" type="myActivity"></nearlist>
	</view>
</template>

<script>
	import nearlist from '@/components/article/near.vue';
	import {userActivity} from "@/common/config/request.js"
	export default{
		data(){
			return {
				listed: [{
					name: '全部活动'
				}, {
					name: '未开始'
				},{
					name: '进行中'
				}, {
					name: '已结束'
				}],
				current: 0,
				user_id:"",//用户id
				hongList:[],
				pageNum: 1,
				totalPage: 0, //总页数
			}
		},
		components:{
			nearlist
		},
		onLoad(option) {
			this.user_id=option.user_id
			this.getMyActivity()
		},
		methods:{
			change(e){
				// console.log(e)
				this.current=e
				this.pageNum=1
				this.hongList=[]
				this.getMyActivity()
			},
			getMyActivity(){
				let data={
					user_id:this.user_id,
					type:this.current,
					page:this.pageNum
				}
				userActivity(data).then(res=>{
					// console.log(res)
					if(res.data.code==1){
						this.totalPage=res.data.data.last_page
						this.hongList=[...this.hongList,...res.data.data.data]
					}
				})
			}
		},
		onReachBottom() {
			if (this.pageNum < this.totalPage) {
				this.pageNum++
				this.getYU()
			} else {
				uni.showToast({
					icon: 'none',
					title: '暂无更多数据'
				})
			}
		}
	}
</script>

<style>
</style>
